﻿using DevelopAssistant.Core.ToolBar;
using DevelopAssistant.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevelopAssistant.Core.ToolBox
{
    public partial class EditSqliteServerConnection : EditDataBaseConnection
    {
        public EditSqliteServerConnection()
        {
            InitializeComponent();
            InitializeControls();
        }

        public EditSqliteServerConnection(DataBaseServer dbserver, LeftMenuBar menubar)
            : this()
        {
            this.txtUserID.Text = dbserver.UserID;
            this.txtPassword.Text = dbserver.Password;
            this.txtDataFilePath.Text = dbserver.Server; //dbserver.DataFilePath;
            this.txtConnectionName.Text = dbserver.Name;
            this.txtDataFilePath.ReadOnly = false;
            this.txtDataFilePath.Enabled = true;
            if (!string.IsNullOrEmpty(dbserver.Password))
            {
                chkLoginStyle.Checked = false;
            }
            else
            {
                chkLoginStyle.Checked = true;
            }
        }

        private void InitializeControls()
        {
            SetBtnApplyEnabled(false);
            this.chkLoginStyle.CheckedChanged +=chkLoginStyle_CheckedChanged;
        }

        private void chkLoginStyle_CheckedChanged(object sender, EventArgs e)
        {
            if (chkLoginStyle.Checked)
            {
                this.groupBox1.Enabled = false;
            }
            else
            {
                this.groupBox1.Enabled = true;
            }
        }

    }
}
